﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mani.Common
{
    public static class NumberHelpers
    {

        public static float Round(this float input, int decimals)
        {            
            return Convert.ToSingle(Math.Round(Convert.ToDecimal(input), decimals, MidpointRounding.ToEven));
        }

        public static double Round(this double input, int decimals)
        {
            return Math.Round(input, decimals, MidpointRounding.ToEven);
        }

        public static double Round(this double? input, int decimals)
        {
            if (!input.HasValue)
                return 0;

            return input.Value.Round(3);
        }
    }
}
